#include "gamehall.h"
#include "ui_gamehall.h"
#include<QPainter>
#include<QPixmap>
#include<QIcon>
#include<QPushButton>
#include<QFont>
#include"gameselect.h"
#include<QSound>
#include<QLabel>
GameHall::GameHall(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::GameHall)
{
    ui->setupUi(this);
    this->setFixedSize(1000,800);
    this->setWindowIcon(QIcon(":image/snake.png"));
    this->setWindowTitle("贪吃蛇游戏");
    QLabel*label=new QLabel(this);
    label->setText("贪吃蛇");
    label->move(400,200);
    label->setStyleSheet("QLabel{font-size:90px;}"
                         "QLabel{font-family: 华文行楷;}"
                         );

    QFont font("华文行楷",24);

    QPushButton*strbt=new QPushButton(this);
    strbt->setFont(font);
    strbt->move(450,500);
    strbt->setText("开始游戏");
    strbt->setStyleSheet("QPushButton{border:0px}");
    strbt->setStyleSheet("QPushButton:hover{background-color:grey;}");


    GameSelect*gameselect=new GameSelect;//实例化新窗口
    connect(strbt,&QPushButton::clicked,[=](){//跳转
        this->close();
        gameselect->setGeometry(this->geometry());
        gameselect->show();//显示新窗口
        QSound::play(":image/clicked.wav");
    });
}

GameHall::~GameHall()
{
    delete ui;
}

void GameHall::paintEvent(QPaintEvent *event)
{
    (void)event;
    QPainter painter(this);
    QPixmap pixmap(":image/background.png");
    painter.drawPixmap(0,0,this->width(),this->height(),pixmap);

}

